<?php $this->load->view('left'); ?>
<script type="text/javascript">
         function createQueryString()
         {
                        var id=encodeURI($("#tree1").val());
                        //alert(id);
                        var querystring={cid:id};
                        return  querystring;
                }
         function second_cate()
         {
                $.ajax({
                        type:"post",
                        url:"second_cate.php",
                        data:createQueryString(),
                        success:function(data){
                                //  alert(decodeURI(data));
                                $("#tree2").html(decodeURI(data));
                                }
                        });
        }

</script>
<h2>Edit Book</h2>
<br />
<br />
<br />
<br />
<ul class="shortcut-buttons-set">
        <li>
                <a class="shortcut-button" href="<?php echo site_url('manage/edit_book'.'/'.$b_id);?>" >
                        <img src="images/a-2.png"  />
                        <!-- <span style="background:#000">Edit Basic Info</span> -->
                </a>
        </li>
        <li>
                <a class="shortcut-button" href="<?php echo site_url('manage/upload_pic'.'/'.$b_id);?>" >
                        <img src="images/b-1.png"  />
                        <!--<span>Edit Book Cover</span>-->
                </a>
        </li>
                 <?php if ($msg['sid'] != 0) { ?>
        <li>
                <a class="shortcut-button" href="<?php echo site_url('manage/upload_plist'.'/'.$b_id);?>" >
                        <img src="images/c-1.png"  />
                        <!--<span>Edit Book Dir</span>-->
                </a>
        </li>
        <li>
                <a class="shortcut-button" href="<?php echo site_url('manage/upload_book'.'/'.$b_id);?>" >
                        <img src="images/d-1.png"  />
                        <!--<span>Edit Book Content</span>-->
                </a>
        </li>
                                        <?php } ?>
</ul>

<br />
<span style="clear:both; display:block; height:5px;"></span>

<form action="<?php echo site_url('manage/update_book_basic'.'/'.$b_id)?>" name="step_one" method="post" enctype="multipart/form-data">
        <table>
                <tr>
                 <?php if ($msg['sid'] > 0) { ?>
                                              <td>Sub Book of:</td>
                                              <td><?php echo $se_name ?></td>
                                              <?php } else { ?>
                 <td>App Store Id:</td><td><input type="text" name="prod_id" id="prod_id" value="<?php echo $msg['pid']?>" /></td>
                         <?php } ?>
                         </tr>
                <tr><td>ISBN:</td><td ><input type="text" name="isbn" id="isbn" value="<?php echo $msg['isbn']?>" /></td></tr>
                <tr><td>Book Name:</td><td ><input type="text" name="name" id="name" value="<?php echo $msg['bn']?>" /></td></tr>
                <tr><td>Author:</td><td ><input type="text" name="author" id="author" value="<?php echo $msg['au']?>"/></td></tr>
                 <?php if($msg['sid'] > 0) { ?>
                <input type="hidden" name="publisher" id="publisher" value="no input value "/>
                <input type="hidden" name="price" id="price" value="0.00"/>
                <input type="hidden" name="ptime" id="ptime" value="1986-10-15"/>
                                             <?php } else { ?>
                <tr><td>Publisher:</td><td ><input type="text" name="publisher" id="publisher" value="<?php echo $msg['pn']?>"/></td></tr>
                <tr><td>Price:</td><td ><input type="text" name="price" id="price" value="<?php echo $msg['pc']?>"/></td></tr>
                <tr><td>Publish Time:</td><td ><input type="text" name="ptime" id="ptime" value="<?php echo $msg['pd']?>"/></td></tr>
                         <?php } ?>
                <tr><td>Book Description:</td><td ><textarea name="describe" rows="15" cols="90" ><?php echo $msg['bd']?></textarea></td></tr>
                 <?php if ($msg['sid'] <=0) { ?>
                <tr>
                        <td>Select Category:</td>
                        <td >
                        <select name="tree1" id="tree1" onchange="return second_cate()" style="width:200px;">
                                <option value=''>Select First Categoty</option>
                                <?php
                                        foreach ($cate as $val)
                                    {
                                                if(isset($slave))
                                                {
                                                if($val['classify_id']==$slave[0]['type_id'])
                                                        {
                                                                 echo "<option selected=\"selected\" value=\"".$val['classify_id']."\" />".$val['type']."</option>";
                                                        }
                                                        else
                                                        {
                                                                 echo "<option  value=\"".$val['classify_id']."\" />".$val['type']."</option>";
                                                        }
                                                }
                                                else
                                                {
                                                        echo "<option  value=\"".$val['classify_id']."\" />".$val['type']."</option>";
                                                }
                                    }
                            ?>

                        </select>
                        <select name="tree2[]" id="tree2" multiple="multiple" style="width:200px;">
                                <?php
                                if(isset($se_cate)&&isset($slave))
                                {
                                        foreach ($se_cate as $se)
                                        {
                                                $p=0;
                                                foreach ($slave as $select)
                                                {
                                                        if($select['type_id']==$se['classify_id'])
                                                        {
                                                                $p=1;
                                                        }
                                                }
                                                if($p==1)
                                                {
                                                        echo "<option selected=\"selected\" value=\"".$se['classify_id']."\" />".$se['type']."</option>";
                                                }
                                                elseif($p==0)
                                                {
                                                        echo "<option value=\"".$se['classify_id']."\" />".$se['type']."</option>";
                                                }
                                        }
                                }
                                ?>
                        </select>
                        </td>
                </tr>
                <tr>

                <td>Recommand:</td>
                <td >
                                       <input type="radio" name="star" value="5" <?php if($msg['star'] == 5){echo "checked=\"checked\"";} ?> /> Recommanded
                                 <input type="radio" name="star" value="4" <?php if($msg['star'] != 5){echo "checked=\"checked\"";} ?> /> Not Recommanded
                </tr>
                                 <?php } ?>
                <tr><td><input type="submit" name="submit" id="submit" value="submit"/></td><td ><input type="reset" name="reset" id="reset" value="reset"/></td></tr>
        </table>

</form>

<?php $this->load->view('right'); ?>
